/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.inscription;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Resource;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.sql.DataSource;

/**
 *
 * @author DIALLO
 */
@WebService(serviceName = "Inscription")
public class Inscription {
    @Resource(name = "ebay")
    private DataSource ebay;

    /**
     * Web service operation
     */
    @WebMethod(operationName = "Inscrire")
    public String Inscrire(@WebParam(name = "id") String id, @WebParam(name = "password") String password) {
        try {
            Connection con = ebay.getConnection();
            PreparedStatement pstmt = con.prepareStatement("insert into EBAY.USERS values ('"+id+"','"+password+"')");
            //pstmt.setInt(parameterIndex, x);
            pstmt.executeUpdate();
            con.close();
            return "Enregistrement avec succès ;-) ";
        } catch (SQLException ex) {
            System.err.println(ex.getMessage());
            return "Erreur, veuillez reprendre l'inscription :-( ";
        }
    }
}
